//
//  AppDelegate.swift
//  Kosspot
//
//  Created by 李鑫 on 2025/7/8.
//


import UIKit
import SwiftUI

class AppDelegate: NSObject, UIApplicationDelegate {
    func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey : Any]? = nil) -> Bool {
        WXApi.registerApp("wx1dee817c3798bf26", universalLink: "https://kosspot.com/")
        WXApi.startLog(by: WXLogLevel(rawValue: 1)!) { error in
            print(error)
        }
        AMapServices.shared().apiKey = "f5865d72bc47cd8380b93b4573027b7c"
        AMapServices.shared().enableHTTPS = true
        AMapLocationManager.updatePrivacyShow(.didShow, privacyInfo: .didContain)
        AMapLocationManager.updatePrivacyAgree(.didAgree)
        if LocationManager().authorizationStatus == .notDetermined {
            LocationManager().requestPermission()
        }
        return true
    }
    
    func application(_ application: UIApplication, configurationForConnecting connectingSceneSession: UISceneSession, options: UIScene.ConnectionOptions) -> UISceneConfiguration {
        return UISceneConfiguration(name: "Default Configuration", sessionRole: connectingSceneSession.role)
    }

    
    
    // 处理微信回调
        func application(_ app: UIApplication, open url: URL, options: [UIApplication.OpenURLOptionsKey : Any] = [:]) -> Bool {
            return WXApi.handleOpen(url, delegate: WeChatManager.shared)
        }
    
        func application(_ application: UIApplication, continue userActivity: NSUserActivity, restorationHandler: @escaping ([UIUserActivityRestoring]?) -> Void) -> Bool {
            return WXApi.handleOpenUniversalLink(userActivity, delegate: WeChatManager.shared)
        }
    
    
    
}
    
    
    
    


